<template>
  <div class="parent">
    <Headers :title="title" />
    <div class="detail">
      <div class="top">
        <h4 class="title">{{titleHeader}}</h4>
        <div class="time">
          <span class="name">{{articleAuthor}}</span>
          <span class="name">{{basicUpdateTime}} {{articleSource}}</span>
        </div>
      </div>
      <div class="content" v-html='articleContent'></div>
    </div>
  </div>
</template>
<script>
import Headers from '@/components/header-return'
import { Indicator } from 'mint-ui'
import axios from 'axios'
import { baseURL } from '@/api/baseUrl'
export default {
  name: 'imgDetail',
  data () {
    return {
      title: '详情',
      titleHeader: '',
      articleSource: '',
      articleAuthor: '',
      basicUpdateTime: '',
      articleContent: ''
    }
  },
  components: {
    Headers
  },
  created () {
    console.log(`${baseURL}/731/detail.do`)
    Indicator.open('Loading...')
    if (this.$route.query.id === '1' && this.$route.query.id !== '' && this.$route.query.id !== null && this.$route.query.id !== 'undefined') {
      axios.get(`${baseURL}/731/detail.do`).then(res => {
        console.log(this.titleHeader)
        this.titleHeader = res.data.basicTitle
        this.articleSource = res.data.articleSource
        this.articleAuthor = res.data.articleAuthor
        this.basicUpdateTime = res.data.basicUpdateTime
        this.articleContent = res.data.articleContent.replace(/style="font-size: 24px;"/g, 'style="font-size: 16px"')
        Indicator.close()
      })
    } else if (this.$route.query.id === '2' && this.$route.query.id !== '' && this.$route.query.id !== null && this.$route.query.id !== 'undefined') {
      axios.get(`${baseURL}/730/detail.do`).then(res => {
        this.titleHeader = res.data.basicTitle
        this.articleSource = res.data.articleSource
        this.articleAuthor = res.data.articleAuthor
        this.basicUpdateTime = res.data.basicUpdateTime
        this.articleContent = res.data.articleContent.replace(/<p>/g, '<p style="font-size: 16px">')
        Indicator.close()
      })
    }
    if (this.$route.query.basicId !== null && this.$route.query.basicId !== '' && this.$route.query.basicId !== 'undefined') {
      axios.get(`${baseURL}/${this.$route.query.basicId}/detail.do`).then(res => {
        this.titleHeader = res.data.basicTitle
        this.articleSource = res.data.articleSource
        this.articleAuthor = res.data.articleAuthor
        this.basicUpdateTime = res.data.basicUpdateTime
        this.articleContent = res.data.articleContent.replace(/<p>/g, '<p style="font-size: 16px">')
        Indicator.close()
      })
    }
  }
}
</script>
<style scoped lang="scss">
.parent{
  width: 100%;
  height: 100%;
  background: #f9f9f9;
  display: flex;
  flex-direction: column;
}
.detail{
  width: 100%;
  overflow-y: auto;
}
.top{
  width: 100%;
  height: 96px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 5px 16px;
  .title{
    font-size:18px;
    font-family:PingFangSC-Regular;
    color:rgba(51,51,51,1);
  }
  .time{
    width: 100%;
    height: 20px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px;
    .name{
      font-size:12px;
      font-family:PingFangSC-Regular;
      font-weight:400;
      color:rgba(159,158,168,1);
    }
  }
}
.content{
  margin-top: 10px;
  padding: 0 10px;
  padding-bottom: 30px;
  p{
    font-size: 16px;
  }
  span{
    font-size: 16px;
  }
}
</style>
